package com.ctg.sysmgr.sso.client.control.util;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

public class LoginStatuHelper {
	
	public static void sendLoginStatu(HttpServletResponse response, String url, String ret, String msg) {
		
		String script = buildScript(url, ret, msg);
		
		response.setContentType("text/html;charset=UTF-8");
		try{
			PrintWriter out = response.getWriter();
	        out.print(script);
	        out.flush();
	        out.close();
	    }catch(Exception e){
	    	e.printStackTrace();
	    }
		
	}
	
	private static String buildScript(String url, String ret, String msg){
		StringBuffer sb = new StringBuffer();
		sb.append("<html><body><script type=\"text/javascript\">");
		sb.append("location.replace(\"");
		sb.append(url);
		sb.append("?ret=");
		sb.append(ret);
		sb.append("&msg=");
		sb.append(msg);
		sb.append("\");");
		sb.append("</script></body></html>");
		
		return sb.toString();
	}

}
